<template>
  <div class="plat-form-wrap">
    <div class="body-wrap home-mini-width pt40">
      <TitleCard
        title="佛山市重点产业专利专题数据库"
        :showMore="false"
        :loading="loading"
        :isEmpty="isEmpty"
        :isSwitch="false"
        :type="'threeCard'"
      >
        <TableCard :tableList="talentList" @moreChange="moreChange"></TableCard>
      </TitleCard>
      <Pagination :total="total" @pageChange="handleChange"></Pagination>
    </div>
  </div>
</template>

<script>
import Pagination from '@/components/common/Pagination'
import TableCard from '@/components/common/tableCard.vue'
import { mapGetters } from 'vuex'
import mixinsBackStack from '@/views/backstageSupport/mixins'
import { talentList } from './config'
import { addByPatent } from '@/api/oprationStatistics'
import { getTimeLimit } from '@/api/linkManage'
import { getBlackHorse } from '@/api/frontCommon'
import FrontMixins from '@/mixins/frontMixin'
import { getStorage } from '@/utils/index'

export default {
  mixins: [mixinsBackStack, FrontMixins],
  data() {
    return {
      talentList,
      bgImg: require('@/assets/images/patentBanner.png'),
      policyParams: {
        pageSize: 10,
        pageNum: 1,
      },
      loading: false,
      isEmpty: false,
      total: talentList.length,
      token:''
    }
  },
  components: {
    TableCard,
    Pagination
  },
  created() {
    this.token = `${getStorage('token', 0)}`
  },
  computed: {
    ...mapGetters('user', ['visitor']),
  },
  methods: {
    async moreChange(item) {
      const result = await getTimeLimit(5)
      if (result.data == 0) return this.info()  //后台限制
      const { msg, code } = await getBlackHorse() //限制登录和企业用户
      if (code !== 200) return this.$message.warning(msg)
      const { id } = item
      window.open(`https://www.himmpat.com/lib/foshanThematicLibrary?cipher=${this.token}&id=${id}`)
      await addByPatent()
    },
    toDetail(id) {
      this.$router.push({ name: 'generalInfoDetails', query: { id } })
    },
    // 切换页面
    handleChange(e) {
      this.params.pageNum = e
      this.initDefaultValue()
    },
  }
}
</script>
